Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development
How objects are instantiated using prepareInstance
This section outlines the steps necessary to bring a container window or other container object into being at run time using the cached Repository information. If you want to understand more about exactly how containers are created, you can study the relevant code in the ADM2 support procedure
src/adm2/container.p, as well as the dynamic window procedurery/uib/rydyncontw.w.When an object is launched, whether it is by
launchContainer,constructObject, or just from the editor, a Repository Manager function calledprepareInstanceis called from the main block of the base ADM property include filesmrtprop.i.This is just about the earliest that anything can run in the ADM world, and the call must be as early as possible so that theADMPropstemp-table, where all of each object’s attributes are held, is built as soon as possible.The
prepareInstancefunction attempts to determine the logical name of the object being launched, since this is what is used to retrieve the objects from the Repository. It does this by calling a function calledgetCurrentLogicalNamein the procedure that launched the object being run. This function is defined in the Session Manager (which containslaunchContainer, the primary starting point for objects run from the menu), the dynamic container procedurerydyncontw.w, the dynamic viewerrydynviewv.w, and the dynamic TreeViewrydyntreew.w.The value returned by
getCurrentLogicalNamecan be in one of two forms (errors and blanks excepted):If there is a single valid object name, rather than the form
InstanceId=*, the relevant data is retrieved from either the cache or the Repository, usingcacheObjectOnClient. Once this data is returned, the ADMProps temp-table is constructed based on the object's attribute buffer.The
InstanceIDADM attribute is set at this point. Each object that is run will have a uniqueInstanceID.The reason for the two different forms of the return value of
getCurrentLogicalNameis that when you are instantiating a master object (which would be the container of other objects), the function returns the actual logical object name that you want to retrieve. When you want to retrieve object instances within a container, the function returns theInstanceId=form. This is because there might be many records with the contained instance’s logical object name. If a toolbar is placed on many windows, for example, there will be one record for the master and one for each object instance. By contrast, there can only be one record with a particular instance ID (tRecordIdentifier).Consider a window called
window1. It contains an SDO calledfullo1and a browser calledbrowser1. If you launchwindow1from a menu,launchContainersets theCurrentLogicalNamevalue towindow1before running the dynamic container object (the procedurerydyncontw.w). Whenrydyncontw.wruns, it picks up the logical object name and passes that into the functioncacheObjectOnClient, which then retrieves into the cache the five sets of object records that make up the window:Two standard ADM2 support procedures in the container class have been extended for Progress Dynamics to create dynamic containers from cached Repository data as opposed to simply running static procedure objects, as would be the case with a standard Version 9 ADM2 application. These are
createobjectsandconstructObject.As
window1in created, the ADM container startup code runscreateobjects. This procedure has the responsibility of creating the objects that are to appear onwindow1.createobjectsretrieves theInstanceIDproperty ofwindow1and then makes sure that the correctcache_Objectrecord is available, by callinggetCacheObjectBufferand passing in theInstanceID. ThisInstanceIDis used to build a query to loop through all of the contained instances (...WHERE tContainerRecordIdentifier = dInstanceID).The framework then runs
constructObjectto constructbrowser1andfullo1. The code must make sure that the correct set of attributes is used for the instance of each object onwindow1, so it sets theCurrentLogicalNametoInstanceid= since this is already available.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |